package or;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class T1402 {

    public int maxSatisfaction(int[] satisfaction) {
        Arrays.sort(satisfaction);
        int len = satisfaction.length;
        int max=0,sum=0,sums=0;
        for (int i = len-1; i >=0 ; i--) {
            sum+=satisfaction[i];
            sums+=sum;
            max=Math.max(max,sums);
        }
        return max;

    }

    @Test
    public void test() {


//        int[] re = {1, 0, -1, 2, -2, -4, 9, 3, 3};
        int[] re={1,2};

        System.out.println(maxSatisfaction(re));
    }
}
